package com.dao;

import com.entity.MeishiCollectionEntity;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.plugins.pagination.Pagination;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.entity.view.MeishiCollectionView;
import org.apache.ibatis.annotations.Select;

/**
 * 健康食谱收藏 Dao 接口
 *
 * @author 
 */
@Mapper
public interface MeishiCollectionDao extends BaseMapper<MeishiCollectionEntity> {

   List<MeishiCollectionView> selectListView(Pagination page,@Param("params")Map<String,Object> params);

   // 查询用户收藏的美食ID列表
   @Select("SELECT meishi_id FROM meishi_collection WHERE yonghu_id = #{userId}")
   List<String> findMeishiIdsByUserId(@Param("userId") String userId);

   // 查询所有用户的收藏记录
   @Select("SELECT yonghu_id, meishi_id FROM meishi_collection")
   List<Map<String, Object>> findAllUserMeishiRelations();

   /**
    * 查询美食收藏数量
    * @return 美食ID和收藏数量的映射列表
    */
   @Select("SELECT meishi_id, COUNT(*) as collection_count FROM meishi_collection GROUP BY meishi_id ORDER BY collection_count DESC")
   List<Map<String, Object>> selectMeishiCollectionCounts();
}
